package cn.tedu.supermarket.controller;

import cn.tedu.supermarket.entity.GoodsUser;
import cn.tedu.supermarket.mapper.GoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class SelectGoodsController {
    @Autowired
    GoodsMapper goodsMapper;

    @RequestMapping("/bGoods")
    public String selectGoodsByCata(String cata, Model model){
        List<GoodsUser> list = goodsMapper.selectGoodsByCata(cata);
        model.addAttribute("list",list);
        return "buy_user/buserMore";
    }
    @RequestMapping("/selectByName")
    public String selectGoodsByName(String keyword, Model model){
        System.out.println(keyword);
        List<GoodsUser> list = goodsMapper.selectGoodsByName(keyword);
        model.addAttribute("list",list);
        return "buy_user/buserMore";
    }


    @RequestMapping("/sGoods")
    public String buyGoodsByCata(String cata, Model model){
        List<GoodsUser> list = goodsMapper.selectGoodsByCata(cata);
        model.addAttribute("list",list);
        return "sel_user/suserMore";
    }
    @RequestMapping("/selByName")
    public String selGoodsByName(String keyword, Model model){
        System.out.println(keyword);
        List<GoodsUser> list = goodsMapper.selectGoodsByName(keyword);
        model.addAttribute("list",list);
        return "sel_user/suserMore";
    }
}
